<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="java.io.*"%>
<%@ page import="xml.response.*"%>
<%@ page import="xml.root"%>
<%@ page import="util.print.printLogCat"%>
<%@ page import="org.sql.table.*"%>
<%@ page import="xml.var"%>
<%@ page import="java.util.Vector"%>
<%@ page import="java.util.Enumeration"%>
<%@ page import="jqgrid.jqgrid"%>
<%@ page import="requestInterFace.Handle.*"%>
<%@ include file="../../util/paramPrint.jsp" %>
<%@ page trimDirectiveWhitespaces="true" %> 
<%   

    /*********** jqgrid ******************/
		jqgrid jq=new jqgrid();
		jq.setRows(request.getParameter(jqgrid._rows));
		jq.setSord(request.getParameter(jqgrid._sord));
		jq.setSortname(request.getParameter(jqgrid._sortname));
		jq.setPage(request.getParameter(jqgrid._page));
		jq.setOper(request.getParameter(jqgrid._oper));
		jq.setSearch(request.getParameter(jqgrid._search));
		/*************************************/
		
		
String Product_ID = request.getParameter("Product_ID");
String name = request.getParameter("Product_Name");
String Product_Type = request.getParameter("Product_Type");
String userType=(String)session.getAttribute("User_Type");
String userID=(String)session.getAttribute("User_ID");
root root=new root();

		productinfo1_1 user=new productinfo1_1();
		user.setLimit((jq.getPageInt()-1)*jq.getRowsInt(), jq.getRowsInt());
		user.setResultField("Product_ID").setResultField("Product_Name").setResultField("Product_Price").
		setResultField("Product_Type").setResultField("Product_DESC").
		setResultField("Product_DESC");
		if(jq.getSortname()!=null&&!jq.getSortname().equals("")){
		user.setOrder(jq.getSortname(),jq.getSord());
		}
		if(Product_ID!=null&&(!Product_ID.equals(""))){
		 user.addequwhile("Product_ID"," like ","%"+Product_ID+"%");
		}
		if(name!=null&&(!name.equals(""))){
		 user.addequwhile("Product_Name"," like ","%"+java.net.URLDecoder.decode(name,"UTF-8")+"%");
		}
		if(Product_Type!=null&&!Product_Type.equals("")&&!java.net.URLDecoder.decode(Product_Type,"UTF-8").equals("全部")){
		 user.addequwhile("Product_Type"," like ","%"+java.net.URLDecoder.decode(Product_Type,"UTF-8")+"%");
		}
		Vector d=user.getTableFactroy();
		root.setRecords(""+d.size());//设置当前查询到的记录数
		int pageNum=user.getCount()/jq.getRowsInt();
		if((user.getCount()%jq.getRowsInt())>0){
			pageNum++;
		}
		root.setTotal_Count(""+pageNum);//查询到的总记录数数
		root.setLimit_Offset(""+jq.getPage());//当前查询页面
		for(int i=0;i<d.size();i++){
			productinfo1_1 u=(productinfo1_1)d.elementAt(i);
		Enumeration e=u.getTable().elements();
		response res=new response();
		res.setAttribute_Id(""+i);
	for(int j=0;j<u.getResultFieldNum();j++){
			String field=(String)u.getSql().getResultField().elementAt(j);
			var v=(var)u.getTable().get(field);
	if(userType!=null&&userType.equals("3")&&field.equals("Product_Price")){
	//客户
	userProductHandle userhandle=new userProductHandle();
	v.setValue(""+userhandle.getUser_Product_Proice(userID,u.getFieldsStr("Product_ID")));
	res.put(v.getName(),v);
	}else{
		res.put(v.getName(), v);
	}
			
    		
		}
		root.addResponse(res);
		}
		//printLogCat.printlnWriter(root.getXmlString());
		String rep=root.getXmlString();
%>
<%=rep%>
